package redis.clients.jedis;

import java.io.IOException;
import java.net.Socket;

import redis.clients.jedis.exceptions.JedisConnectionException;

/**
 * JedisSocketFactory: responsible for creating socket connections
 * from the within the Jedis client, the default socket factory will
 * create TCP sockets with the recommended configuration.
 * <p>
 * You can use a custom JedisSocketFactory for many use cases, such as:
 * - a custom address resolver
 * - a unix domain socket
 * - a custom configuration for you TCP sockets
 * <p>
 * <p>
 * JedisSocketFactory 是一个用于创建 Jedis 连接的工厂类。
 * 它负责将网络连接封装成 Jedis 对象，以便在应用程序中使用。
 * JedisSocketFactory 通常与 JedisPool 一起使用，以实现连接池的功能。
 */
public interface JedisSocketFactory {

    /**
     * WARNING: Throwing IOException will not be supported in future.
     *
     * @return Socket
     * @throws IOException              this will be removed in future
     * @throws JedisConnectionException
     */
    Socket createSocket() throws IOException, JedisConnectionException;

    void updateHostAndPort(HostAndPort hostAndPort);

    @Deprecated
    String getDescription();

    @Deprecated
    String getHost();

    @Deprecated
    void setHost(String host);

    @Deprecated
    int getPort();

    @Deprecated
    void setPort(int port);

    @Deprecated
    int getConnectionTimeout();

    @Deprecated
    void setConnectionTimeout(int connectionTimeout);

    @Deprecated
    int getSoTimeout();

    @Deprecated
    void setSoTimeout(int soTimeout);
}
